package com.ymttest.database.mongo;

import java.util.ArrayList;
import java.util.Map;

import com.ymt.database.MongoDBDriver;

public class ActivityProductModelWapper {
	
	MongoDBDriver mdd = YmtMongoDriverFactroy.getInstance_YmtProductDBdriverNew("ActivityProductModel");

	public ActivityProductModelWapper()  {
	}
		

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Map<String,Object> getLastActivityProductMapByProductId(String productId) throws Exception {
		ArrayList<Map> list = mdd.selectPartLimitToMap("{\"ProductId\":\"" + productId + "\"}",null, 1, "{_id:-1}");
	    
	    return list.size() > 0 ? list.get(0) : null;
	}
	
	
	
	@SuppressWarnings({"rawtypes" })
	public ArrayList<Map> getActivityMapByProductId(String productId) throws Exception {
		ArrayList<Map> list = mdd.selectPartLimitToMap("{\"ProductId\":\"" + productId + "\"}",101);
	    
	    return list;
	}
	
	public static void main(String[] args) throws Exception {
		ActivityProductModelWapper wapper = new ActivityProductModelWapper();
		Map<String,Object> map = wapper.getLastActivityProductMapByProductId("8a042299-9fdf-474c-a5aa-1c2dcfc0fe64");
		System.out.println(map != null);
	}
}
